<include file="Public/min-header" />
<div class="wrapper">
    <include file="Public/breadcrumb" />
    <section class="content">
        <div class="row">
            <div class="col-xs-12">
                <div class="box">
                    <div class="box-header">
                        <nav class="navbar navbar-default">
                            <div class="collapse navbar-collapse">
                                <div class="navbar-form row">
                                    <div class="col-md-2">
                                        <a href="{:U('Jifen/addEditType')}" class="btn btn-primary">
                                            <i class="fa fa-plus"></i>新增分类</a>
                                    </div>
                                </div>
                            </div>
                        </nav>
                    </div>
                    <!-- /.box-header -->
                    <div class="box-body">
                        <div class="row">
                            <div class="col-sm-12">
                                <table id="list-table" class="table table-bordered table-striped dataTable" role="grid" aria-describedby="example1_info">
                                    <thead>
                                        <tr role="row">
                                            <th valign="middle">分类ID</th>
                                            <th valign="middle">名称</th>
                                            <th valign="middle">排序</th>
                                            <th valign="middle">操作</th></tr>
                                    </thead>
                                    <tbody>
                                        <foreach name="jifen_type" item="vo" key="k">
                                            <tr>
                                                <td>{$vo.type_id}</td>
                                                <td>{$vo.type_name}</td>
                                                <td>
                                                    <input type="text" value="{$vo.sort_type}" onchange="updateSort('jifen_type','type_id','{$vo.type_id}','sort_type',this)" size="4" value="{$vo.sort_type}" onkeyup="this.value=this.value.replace(/[^\d]/g,'')" onpaste="this.value=this.value.replace(/[^\d]/g,'')" class="input-sm" /></td>
                                                <td>
                                                    <a class="btn btn-primary" href="{:U('Jifen/addEditType',array('type_id'=>$vo['type_id']))}">
                                                        <i class="fa fa-pencil"></i>
                                                    </a>
                                                    <a class="btn btn-danger" href="javascript:del_fun('{:U('Jifen/delType',array('type_id'=>$vo['type_id']))}');">
                                                        <i class="fa fa-trash-o"></i>
                                                    </a>
                                                </td>
                                            </tr>
                                        </foreach>
                                    </tbody>
                                </table>
                            </div>
                        </div>
                    </div>
                    <!-- /.box-body --></div>
                <!-- /.box --></div>
        </div>
    </section>
</div>
<script type="text/javascript">// 展开收缩

    // 以下是 bootstrap 自带的  js
    function rowClicked(obj) {
        span = obj;
        obj = obj.parentNode.parentNode;
        var tbl = document.getElementById("list-table");
        var lvl = parseInt(obj.className);
        var fnd = false;
        var sub_display = $(span).hasClass('glyphicon-minus') ? 'none': '' ? 'block': 'table-row';
        //console.log(sub_display);
        if (sub_display == 'none') {
            $(span).removeClass('glyphicon-minus btn-info');
            $(span).addClass('glyphicon-plus btn-warning');
        } else {
            $(span).removeClass('glyphicon-plus btn-info');
            $(span).addClass('glyphicon-minus btn-warning');
        }
        for (i = 0; i < tbl.rows.length; i++) {
            var row = tbl.rows[i];
            if (row == obj) {
                fnd = true;
            } else {
                if (fnd == true) {
                    var cur = parseInt(row.className);
                    var icon = 'icon_' + row.id;
                    if (cur > lvl) {
                        row.style.display = sub_display;
                        if (sub_display != 'none') {
                            var iconimg = document.getElementById(icon);
                            $(iconimg).removeClass('glyphicon-plus btn-info');
                            $(iconimg).addClass('glyphicon-minus btn-warning');
                        } else {
                            $(iconimg).removeClass('glyphicon-minus btn-info');
                            $(iconimg).addClass('glyphicon-plus btn-warning');
                        }
                    } else {
                        fnd = false;
                        break;
                    }
                }
            }
        }
        for (i = 0; i < obj.cells[0].childNodes.length; i++) {
            var imgObj = obj.cells[0].childNodes[i];
            if (imgObj.tagName == "IMG") {
                if ($(imgObj).hasClass('glyphicon-plus btn-info')) {
                    $(imgObj).removeClass('glyphicon-plus btn-info');
                    $(imgObj).addClass('glyphicon-minus btn-warning');
                } else {
                    $(imgObj).removeClass('glyphicon-minus btn-warning');
                    $(imgObj).addClass('glyphicon-plus btn-info');
                }
            }
        }
    }</script>
</body>

</html>